/**
 * jgamebox
 *
 * outlook@China software studio
 * Copyright (c) 2008-2011. All Rights Reserved.
 * http://www.outlook.com
 */

package org.outlook.common.measure;

/**
 * function:
 * 
 * @author watson email: watson.wu@hotmail.com
 * @date 2011-5-30
 */
public class Speed implements Cloneable {

	private int[] speeds = new int[3];
	
	private int x;//pixels per 0.05 seconds
	private int y;
	private int z;

	public Speed() {
		this(0,0,0);
	}

	public Speed(int x, int y, int z) {
		setX(x);
		setY(y);
		setZ(z);
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
		speeds[0] = this.x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
		speeds[1] = this.y;
	}

	public int getZ() {
		return z;
	}

	public void setZ(int z) {
		this.z = z;
		speeds[2] = this.z;
	}
	
	public int get3DOffset() {
		final Double sqrt = Math.sqrt(x*x+y*y+z*z);
		return sqrt.intValue();
	}

	@Override
	public String toString() {
		return new StringBuilder().append("Speed[").append(getX()).append(",").append(getY()).append(",").append(getZ()).append("]").toString();
	}

}
